Skip to content

Request Github token from Taskcluster's auth service - #825

Open
ahal wants to merge 2 commits into
mozilla-releng:mainfrom
ahal:ahal/lnqrmntzxuxr
Open

ahal wants to merge 2 commits into
mozilla-releng:mainfrom
ahal:ahal/lnqrmntzxuxr

Conversation

@ahal

@ahal ahal commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@ahal ahal self-assigned this Sep 2, 2026
@ahal

ahal commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

This still needs:

  1. Testing
  2. Scopes granted to all the scriptworker clients for the auth service
  3. App to be installed in all repositories that need this

Though I might land this before steps 2 and 3 just to verify the fallback is working.

@ahal
ahal force-pushed the ahal/lnqrmntzxuxr branch from 56430bf to 94eff61 Compare September 2, 2026 18:04
Comment thread src/scriptworker/github.py Outdated
Comment thread src/scriptworker/cot/verify.py Outdated
Comment on lines -1213 to +1212
github_repo = GitHubRepository(owner=repo_definition["parent"]["owner"]["login"], repo_name=repo_definition["parent"]["name"], token=token)
github_repo = GitHubRepository(context, repo_definition["parent"]["owner"]["login"], repo_definition["parent"]["name"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to be a problem? If I open a PR from github.com/Eijebong/foo for github.com/mozilla-releng/foo, the task won't have scopes to get a read token for Eijebong/foo and the tc-auth token request will fail 100% of the time.
I'm not sure how we can do that but we probably want to use a read token minted for the parent repo and use that instead? AFAIK that'd work for public repos but not private ones though (although all fork commits are accessible on the parent directly, maybe that's enough to make this whole branch useless?).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking more about this, I think the private repo part of this is the same anyway since the token passed a secret wouldn't have access to it either

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

As implemented this won't be an immediate problem because we fallback to github_oauth_token if there's a problem fetching the token from the auth service.

But assuming the goal is to get rid of github_oauth_token, we'd need to implement something like this.

I'm thinking of leaving the github_oauth_token fallback for this PR, but add a comment to make sure we don't forget about the fork case when we eventually go to remove it?

Comment thread src/scriptworker/github.py Outdated
@ahal
ahal force-pushed the ahal/lnqrmntzxuxr branch 2 times, most recently from a01199e to 1afe69b Compare September 8, 2026 15:05
This is the first version that implements the auth service's ability to
hand out Github tokens.
…possible

If there's an error (e.g missing scopes or app not installed on the
target repo), we fallback to the existing github_oauth_token.
@ahal

ahal commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Here's a task demonstrating the fallback to GITHUB_OAUTH_TOKEN working:
https://firefox-ci-tc.services.mozilla.com/tasks/I3dW2n0nRXu_BJIA8hdvRQ/runs/0/logs/public/logs/chain_of_trust.log

And here it is with scopes, but still hitting the fallback due to the app not being installed:
https://firefox-ci-tc.services.mozilla.com/tasks/I3dW2n0nRXu_BJIA8hdvRQ/runs/1/logs/public/logs/chain_of_trust.log

And here it is using the auth service token:
https://firefox-ci-tc.services.mozilla.com/tasks/I3dW2n0nRXu_BJIA8hdvRQ/runs/2/logs/public/logs/chain_of_trust.log

(but still using the fallback on a docker-image task that came from the upstream repo because I didn't grant the scopes / install the app there)

@ahal
ahal force-pushed the ahal/lnqrmntzxuxr branch from 1afe69b to d094e19 Compare September 25, 2026 14:18
@ahal
ahal marked this pull request as ready for review September 25, 2026 14:18
@ahal
ahal requested a review from a team as a code owner September 25, 2026 14:18
@ahal
ahal requested a review from Eijebong September 25, 2026 14:18
@ahal

ahal commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

One thing I'm undecided about.. do we want to print the full Taskcluster failure message including the regular scope error?

On the one hand it's pretty noisy, but noisy might be a good thing. CoT makes a lot of requests and we already started exceeding moz-releng-automation's rate limit upon migrating build-components to Github clones. So we're going to want to make the app installation a requirement eventually

@ahal

ahal commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

And by eventually I mean sooner rather than later

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants